import java.util.ArrayList;

import Gameplay.Level;
import Gameplay.Player;
import Project.LocalMap;
import Project.Main;
import Project.SaveFile;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class LevelTest extends TestCase {
	public static Test suite() {
		return new TestSuite(LevelTest.class);
	}
	
	public void testCreate() {
		SaveFile.LoadFile(0, true);
		Main main = new Main();
		
		Level test1 = new Level(0, new LocalMap(0), false);
		Level test2 = new Level(1, new LocalMap(0), false);
		Level test3 = new Level(2, new LocalMap(0), false);
		
		
		main.setCurrentUI(test1);
		
		int levelsBeaten = SaveFile.getCurrentFile().getLevelsBeaten();
		test1.startLevel();
		Assert.assertTrue(test1.getWaves().size() == 2);
		test1.loseLevel();
		Assert.assertTrue(SaveFile.getCurrentFile().getLevelsBeaten() == levelsBeaten);
		
		main.setCurrentUI(test2);
		
		test2.startLevel();
		Assert.assertTrue(test2.getWaves().size() == 2);
		test2.beatLevel();
		Assert.assertFalse(SaveFile.getCurrentFile().getLevelsBeaten() != levelsBeaten);
		
		main.setCurrentUI(test3);
		
		test3.startLevel();
		int frames = test3.getFrameRate();
		
		Assert.assertTrue(frames == 90);
		test3.setFrameRate(45);
		Assert.assertTrue(frames != test3.getFrameRate());
		
		ArrayList<Gameplay.OnScreenObject> temp = test3.getObjectList();
		test3.addWave(test3.getWaves().get(1));
		Assert.assertTrue(test3.getObjectList() != temp);
		Assert.assertTrue(test3.getObjectList().size() == temp.size() + 5);
		
	}
}
